import { GTextFormat } from "../../../common/GTextFormat";
import { ObjCreate } from "../common/ObjCreate";
import { WuXingAttrInfo } from "../../model/wuxing/WuXingAttrInfo";
import { HTMLUtil } from "../../../../com/gengine/utils/HTMLUtil";
import { Language } from "../../../../extend/language/Language";
import { GlobalStyle } from "../../../common/global/GlobalStyle";
import { EffectManager } from "../../manager/EffectManager";
import { GlobalClass } from "../../../../com/mui/core/GlobalClass";
import { ImagesConst } from "../../resource/ImagesConst";
import { ColorConfig } from "../../resource/ColorConfig";
type int = number;
//class WuXingRefreshItem
    
    export  class WuXingRefreshItem /* flash.display.Sprite */
    {
        constructor()
        {
            
            this.initUI();
            mouseEnabled = false;
            mouseChildren = false;
            this._height = 20;
            return;
        }

        /* internal  */updateImgAttr(): void
        {
            var loc1=null;
            if (!this._attrTxt) 
            {
                loc1 = new GTextFormat("", 12, 16777215);
                loc1.letterSpacing = 2;
                this._attrTxt = ObjCreate.createTextField("", 15, 0, 80, 20, this, loc1);
            }
            if (!this._attrTxt.parent) 
            {
                addChild(this._attrTxt);
            }
            this._wxValueTxt.x = 90;
            this._optBmp.x = 115;
            return;
        }

        protected initUI(): void
        {
            this._wxValueTxt = ObjCreate.createTextField("", 100, 0, 22, 22, this);
            this._wxValueTxt.textColor = 16711680;
            this._wxValueTxt.mouseEnabled = false;
            this._optBmp = new Object /* flash.display.Bitmap */();
            this._optBmp.y = 0;
            addChild(this._optBmp);
            this.updateImgAttr();
            return;
        }

        public updateData(arg1: WuXingAttrInfo, arg2: Boolean=false): void
        {
            this._textColor = arg2;
            this._attrInfo = arg1;
            this._wxValueTxt.text = this._attrInfo.value.toString();
            if (arg1.curAttr) 
            {
                this.showOptBmp(arg1.lock);
                this._attrTxt.htmlText = HTMLUtil.addColor(Language.getStringByParam(26392, arg1.name), GlobalStyle.color1);
            }
            else 
            {
                this.showOptBmp(arg1.compare > 0);
                this.showTextColor(arg2);
            }
            return;
        }

        public updateLockMainAttr(): void
        {
            if (this._attrInfo.curAttr) 
            {
                this.showOptBmp(this._attrInfo.lock);
            }
            return;
        }

        /* internal  */showOptBmp(arg1: Boolean): void
        {
            EffectManager.glowFilterUnReg(this._optBmp);
            if (this._attrInfo.curAttr) 
            {
                this._wxValueTxt.textColor = 65280;
                this._optBmp.bitmapData = GlobalClass.getBitmapData(ImagesConst.RecastAttribute_Lock);
            }
            else 
            {
                this._wxValueTxt.textColor = 16711680;
                this._optBmp.bitmapData = GlobalClass.getBitmapData(ImagesConst.RangeRaise);
            }
            if (arg1) 
            {
                if (this._attrInfo.curAttr) 
                {
                    if (!contains(this._optBmp)) 
                    {
                        addChild(this._optBmp);
                    }
                }
                else 
                {
                    if (this._textColor) 
                    {
                        if (!contains(this._optBmp)) 
                        {
                            addChild(this._optBmp);
                        }
                        EffectManager.glowFilterReg(this._optBmp);
                    }
                    else if (contains(this._optBmp)) 
                    {
                        removeChild(this._optBmp);
                    }
                    this._wxValueTxt.textColor = 16776960;
                }
            }
            else if (contains(this._optBmp)) 
            {
                removeChild(this._optBmp);
            }
            return;
        }

        /* internal  */showTextColor(arg1: Boolean): void
        {
            if (arg1) 
            {
                this._attrTxt.htmlText = HTMLUtil.addColor(Language.getStringByParam(26392, this._attrInfo.name), ColorConfig.instance.getWuxingColor(this._attrInfo.key));
            }
            else 
            {
                this._attrTxt.htmlText = HTMLUtil.addColor(Language.getStringByParam(26392, this._attrInfo.name), GlobalStyle.color1);
            }
            return;
        }

        public dispose(): void
        {
            this._attrInfo = null;
            EffectManager.glowFilterUnReg(this._optBmp);
            if (contains(this._optBmp)) 
            {
                removeChild(this._optBmp);
            }
            return;
        }

        public /* override */ set height(arg1: number)
        {
            this._height = arg1;
            return;
        }

        public /* override */ get height(): number
        {
            return this._height;
        }

        /* internal */ /* var */_attrInfo: WuXingAttrInfo;

        /* internal */ /* var */_attrTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_wxValueTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_optBmp: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_height: int;

        /* internal */ /* var */_textColor: Boolean;
    }
